/**
 * Created by Administrator on 2018/11/24.
 */
// 基于准备好的dom，初始化echarts实例
var myChart4 = echarts.init(document.getElementById('down3'),'macarons');

var seriesdata1 = [
    [
        //                data:[60,80,45,65,55,65,92,52,74,82,65,83,72,90,55,75,54,57,98,58,89,58,92,82,67,100,70,92,72,83,68,55,64,60,83,64,99,77,82,80,75,93,85,62,76,56,96]

        //30,50,30,50,30,50,30,50,30,50,30,50,90
        60,80,45,65,55,65,78,52,74,82,65,83,72,90,55,75,54,57,70,58,89,58,66,82,67,50,70,88,72,83,68,55,64,60,83,64,87,77,82,80,75,93,85,62,76,56,70
    ]
];
InitChart(seriesdata1);
function InitChart(value){
    // 指定图表的配置项和数据
    var option = {
        //title: {
        //    //text: '堆叠区域图'
        //},
        tooltip : {
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                label: {
                    backgroundColor: '#6a7985'
                    /*
                     *             label: {
                     backgroundColor: '#6a7985'
                     }
                     *
                     *
                     * */
                }
            }
            //formatter: function (params, ticket, callback) {
            //    console.log(params);
            //    return params[0].axisValue;
            //}
        },
        color:['#b3b3ff'],
        legend:[
            {
                show:true,
                orient:'horizontal',
                x:'center',
                top:'3%',
                itemGap: 20,
                data:[
                    //{
                    //    name:'XXXXX1',
                    //    icon:'bar'
                    //},
                    //{
                    //    name:,
                    //
                    //}                 //'XXXXX2'
                ],
                textStyle:{
                    color:'#fff',
                    fontSize:40
                }
            }

        ],
        toolbox: {
            feature: {
                saveAsImage: {}
            }
        },
        grid: {
            left: '50',
            right: '80',
            bottom: '3%',
            containLabel: true
        },
        xAxis : [
            {
                type : 'category',
                boundaryGap : false,
                //data:val,
                data : [
                    //'2018/01','2018/02','2018/03','2018/04','2018/05','2018/06','2018/07'
                    "2018/01",
                    "2018/02",
                    "2018/03",
                    "2018/04",
                    "2018/05",
                    "2018/06",
                    "2018/07",
                    "2018/01",
                    "2018/02",
                    "2018/03",
                    "2018/04",
                    "2018/05",
                    "2018/06",
                    "2018/07",
                    "2018/01",
                    "2018/02"
                ],
                axisLabel:{
                    show:true,
                    textStyle: {
                        color: '#fff',
                        fontSize:40
                    }

                },
                axisLine:{
                    lineStyle:{
                        color: '#56f0ed',
                        width:5
                    }
                }
            }
        ],
        yAxis :
        {
            name:'(%)',
            type : 'value',
            nameTextStyle:{
                color:"#fff",
                fontSize:40
            },
            min : 0,
            max:100,
            interval:10,
            axisLabel: {
                show: true,
                //interval: 'auto',
                //formatter: '{value}%',
                //position: 'left',
                //nameLocation: 'middle',
                //nameGap: 35,
                textStyle: {
                    color: '#fff',
                    fontSize:40
                }
            },
            show: true,
            splitLine:{
                show:false
            },
            axisLine:{
                lineStyle:{
                    color: '#56f0ed',
                    width: 5
                    //type: 'solid'
                }
            }
        },

        series : [

            {
                //name:'XXXXX2',
                type:'line',
                symbol: 'circle',
                symbolSize:25, //拐点圆的大小
                //smooth:true,
                //stack: '总量',
                areaStyle: {
                    color: new echarts.graphic.LinearGradient(
                        0, 0, 0, 1,
                        [
                            {offset: 0, color: 'rgb(13, 103, 254,0)'},
                            {offset: 0.5, color: 'rgb(13, 103, 254,0.8)'},
                            {offset: 1, color: 'rgb(13, 103, 254)'}
                        ]
                    )
                },
                lineStyle: {
                    normal: {
                        width: 5
                    }
                },
                //data:[79,100,55,88,70,80,30],
                markLine: {
                    symbol: ['none', 'none'],//去掉箭头

                    silent: true,
                    itemStyle: {
                        normal: { lineStyle: {width:1, type: 'solid', color:'#ccc' },label: { show: true, position:'left' } }
                    },
                    data:[
                        { name: '最小值',yAxis:0},
                        { name: '最大值',yAxis:90}
                    ]
                    //data:[{yAxis: 20},{yAxis: 40}]
                },
                data:value[0],
                itemStyle:{
                    normal:{
                        color: 'rgb(43, 255, 255)'
                    }
                },
                markArea:{
                }
            }
        ]
    };
// 使用刚指定的配置项和数据显示图表。
    myChart4.setOption(option);
    window.onresize = function() {//监听div和屏幕的改变
        myChart4.resize();//resize属性指定一个元素是否是由用户调整大小的。
    }
}
setInterval(function(){
    var op = myChart4.getOption();
    var opData0 = op.series[0].data;
    //var opData1 = op.series[1].data;
    op.series[0].data.push(opData0.shift());
    //opData0.shift();
    //opData1.shift();
    //op.xAxis[0].data.shift();
    myChart4.setOption(op);
},5000);